package com.cxx.purchasecharge.core.model.persistence;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import com.cxx.purchasecharge.core.model.BaseModel;

/**
 * 货物
 */
@Entity
@Table (name = "pc_goods")
public class Goods extends BaseModel implements Cloneable
{
    private static final long serialVersionUID = 1L;

    private long id;
    private String name;
    
    private String imagePath;
    private String maker;
    private String barCode;
    private String specification;
    private String technicalParameters;
    private String comment;
    /**
     * 进货价
     */
    private float importPrice;
    /**
     * 零售价
     */
    private float retailPrice;
    /**
     * 批发价
     */
    private float tradePrice;

    private boolean available = true;
    private GoodsUnit unit;
    private GoodsType type;
    private GoodsStorage storage;
    private GoodsDepository depository;
    private long userCreatedBy;
    private long userUpdatedBy;

    public Goods ()
    {
    }

    public Goods (String name, float importPrice, float retailPrice, float tradePrice)
    {
        this.name = name;
        this.importPrice = importPrice;
        this.retailPrice = retailPrice;
        this.tradePrice = tradePrice;
    }

    @Id
    @GeneratedValue (strategy = GenerationType.AUTO)
    public long getId ()
    {
        return id;
    }

    public void setId (long id)
    {
        this.id = id;
    }

    @Column (nullable = false, unique = true)
    public String getName ()
    {
        return name;
    }

    public void setName (String name)
    {
        this.name = name;
    }

    public String getImagePath ()
    {
        return imagePath;
    }

    public void setImagePath (String imagePath)
    {
        this.imagePath = imagePath;
    }

    public String getMaker ()
    {
        return maker;
    }

    public void setMaker (String maker)
    {
        this.maker = maker;
    }

    public String getBarCode ()
    {
        return barCode;
    }

    public void setBarCode (String barCode)
    {
        this.barCode = barCode;
    }

    @Column (length = 1024)
    public String getSpecification ()
    {
        return specification;
    }

    public void setSpecification (String specification)
    {
        this.specification = specification;
    }

    @Column (length = 1024)
    public String getTechnicalParameters ()
    {
        return technicalParameters;
    }

    public void setTechnicalParameters (String technicalParameters)
    {
        this.technicalParameters = technicalParameters;
    }

    @Column (length = 2048)
    public String getComment ()
    {
        return comment;
    }

    public void setComment (String comment)
    {
        this.comment = comment;
    }

    @Column (nullable = false)
    public float getImportPrice ()
    {
        return importPrice;
    }

    public void setImportPrice (float importPrice)
    {
        this.importPrice = importPrice;
    }

    @Column (nullable = false)
    public float getRetailPrice ()
    {
        return retailPrice;
    }

    public void setRetailPrice (float retailPrice)
    {
        this.retailPrice = retailPrice;
    }

    @Column (nullable = false)
    public float getTradePrice ()
    {
        return tradePrice;
    }

    public void setTradePrice (float tradePrice)
    {
        this.tradePrice = tradePrice;
    }

    @ManyToOne
    @JoinColumn(name="unit_id")
    public GoodsUnit getUnit ()
    {
        return unit;
    }

    public void setUnit (GoodsUnit unit)
    {
        this.unit = unit;
    }

    @ManyToOne
    @JoinColumn (name = "type_id")
    public GoodsType getType ()
    {
        return type;
    }

    public void setType (GoodsType type)
    {
        this.type = type;
    }

    @ManyToOne
    @JoinColumn(name="depository_id")
    public GoodsDepository getDepository ()
    {
        return depository;
    }

    public void setDepository (GoodsDepository depository)
    {
        this.depository = depository;
    }

    public boolean isAvailable ()
    {
        return available;
    }

    public void setAvailable (boolean available)
    {
        this.available = available;
    }

    @OneToOne (mappedBy = "goods", cascade =
    { CascadeType.ALL })
    public GoodsStorage getStorage ()
    {
        return storage;
    }

    public void setStorage (GoodsStorage storage)
    {
        this.storage = storage;
    }

    public long getUserCreatedBy()
    {
        return userCreatedBy;
    }

    public void setUserCreatedBy(long userCreatedBy)
    {
        this.userCreatedBy = userCreatedBy;
    }

    public long getUserUpdatedBy()
    {
        return userUpdatedBy;
    }

    public void setUserUpdatedBy(long userUpdatedBy)
    {
        this.userUpdatedBy = userUpdatedBy;
    }
}
